package com.beaven.model.model.card;

import com.beaven.model.model.db.Group;
import com.beaven.model.model.db.Message;
import com.beaven.model.model.db.User;
import java.util.Date;

/**
 * author: Beaven
 * time: 2017/5/18 15:33
 */

public class MessageCard {

  private String id;

  private String content;

  private int type;

  private Date createAt;

  private String groupId;

  private String senderId;

  private String receiverId;

  private transient int status = Message.STATUS_DONE; //当前消息状态

  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }

  public String getContent() {
    return content;
  }

  public void setContent(String content) {
    this.content = content;
  }

  public int getType() {
    return type;
  }

  public void setType(int type) {
    this.type = type;
  }

  public Date getCreateAt() {
    return createAt;
  }

  public void setCreateAt(Date createAt) {
    this.createAt = createAt;
  }

  public String getGroupId() {
    return groupId;
  }

  public void setGroupId(String groupId) {
    this.groupId = groupId;
  }

  public String getSenderId() {
    return senderId;
  }

  public void setSenderId(String senderId) {
    this.senderId = senderId;
  }

  public String getReceiverId() {
    return receiverId;
  }

  public void setReceiverId(String receiverId) {
    this.receiverId = receiverId;
  }

  public int getStatus() {
    return status;
  }

  public void setStatus(int status) {
    this.status = status;
  }

  /**
   * 构建消息元素
   *
   * @param sender 发送者
   * @param receiver 接收者
   * @param group 接收者-群
   * @return 一个消息
   */
  public Message build(User sender, User receiver, Group group) {
    Message message = new Message();
    message.setId(id);
    message.setContent(content);
    message.setType(type);
    message.setCreateAt(createAt);
    message.setReceiveGroup(group);
    message.setSender(sender);
    message.setReceiver(receiver);
    message.setStatus(status);
    return message;
  }
}
